<template>
<div>
  <div class="demo-image"></div>
  <div style="min-height: 700px">
    <el-page-header @back="goBack" content="我的预选单" style="margin-left: 10%">
    </el-page-header>

  <div class="primaryf" v-for="(item) in ecards">
    <div class="primaryc1">
      <img :src='item.eimg' style="width: 150px;height: 150px">
    </div>
    <div class="primaryc2">
      <p>姓名：{{item.ename}}</p>
      <p>职称：{{item.eprofessionalTitle}}</p>
      <p>院系：{{item.ecollege}}</p>
      <p>教研室：{{item.eteachOffice}}</p>
    </div>
    <div class="primaryc3">
      <el-button type="primary" style="margin-right: 20px" @click="queryecard(item.id)">查看</el-button>
      <el-button type="success" @click="deleteecard(user.id,item.id)">删除</el-button>
    </div>
  </div>
  </div>
  <foot style="margin-top: 50px"></foot>
</div>
</template>

<script>
import {queryMyprimary} from "@/api/vcard";
import {delMyprimary} from "@/api/vcard";
import Foot from "@/components/foot";
export default {
  name: "myprimary",
  components: {Foot},
  data() {
    return {
      ecards:[],
      user:{}

    }
  },
  created() {
    if(this.$route.query.uid) {
      queryMyprimary(this.$route.query.uid).then(resp => {
        this.ecards = resp.result
        console.log(this.ecards)
      })
    }

  },
  mounted() {
    this.user=JSON.parse(sessionStorage.getItem("user"))
    console.log(this.user)
  },
  methods:{
    queryecard(eid){
      this.$router.push({
        name : 'ecarddetail',
        query :{
          id : eid
        }
      });
    },
    deleteecard(uid,eid){
      delMyprimary(uid,eid).then(response => {
          if(response.success){
            // console.log(response.message);
            this.$notify({
              title: '成功',
              message: response.message,
              type: 'success'
            });
            this.$router.go(0)

          }else {
            console.log(response.message);
          }
      })
    },
    goBack() {
      history.back()
    }
  },
}
</script>

<style scoped>
.demo-image{
  background :url("../images/top_bg.png") no-repeat;
  background-size: 100% 100%;
  object-fit: cover; /* background-size */ object-position: center;
  height :150px;
  width :100%;
}
.primaryf{
  display: flex;
  box-shadow: 1px 1px 13px 6px #ccc;
  width: 1000px;
  margin: 20px auto;
}
.primaryc1{
  width: 150px;height: 150px;
  margin: 20px auto 20px;
}
.primaryc2{
  width: 400px;
  margin: 20px auto;
  padding: 30px 30px;
}
.primaryc3{
  margin: 75px auto;
}
</style>